﻿#region License statement
// NJamb, a specification and delta-specification DSL
// Copyright (c) 2010-2011, Mark Knell
// Published under the MIT License; all other rights reserved
#endregion

#region using...
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using NJamb.Parser.SubjectBuilders;
using NJamb.Parser.Subjects.Enumerable;
using NJamb.Parser.Subjects.Singular;
using NUnit.Framework;
using Stile.Testing.SampleTypes;
#endregion

namespace NJamb.Tests.Parser.SubjectBuilders
{
    [TestFixture]
    public class SubjectBuilderFixture
    {
        private Expression<Func<Sample>> _hostExpression;
        private SubjectBuilder<Sample> _testSubject;

        [SetUp]
        public void SetUp()
        {
            var sample = new Sample();
            _hostExpression = () => sample;
            _testSubject = new SubjectBuilder<Sample>(_hostExpression);
        }

        [Test]
        public void InitialValues()
        {
            Assert.That(_testSubject.Expression, Is.SameAs(_hostExpression));
        }

        [Test]
        public void That()
        {
            // act
            var subject = _testSubject.That(x => x.Int) as SingularSubject<int>;

            // assert
            Assert.IsNotNull(subject);
            Assert.That(subject.LazyDescription.IsValueCreated, Is.False);
        }

        [Test]
        public void ThatTheSequence()
        {
            // arrange

            // act
            IEnumerableSubject<IEnumerable<int>, int> thatTheSequence = _testSubject.ThatTheSequence(x => x.IntEnumerable);

            // assert
            Assert.That(thatTheSequence.Is, Is.Not.Null);
        }
    }
}
